
<template>
  <BasicLayout>
    <template #wrapper>
      <el-card class="box-card">
        <el-form ref="queryForm" :model="queryParams" :inline="true">
          <el-form-item label="用户姓名" prop="name">
            <el-input
              v-model="queryParams.name"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="用户账号" prop="account">
            <el-input
              v-model="queryParams.account"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="提现时间" prop="tx_time">
            <el-date-picker
              v-model="queryParams.tx_time"
              type="date"
              size="small"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>

          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>

        <el-table
          v-loading="loading"
          :data="sysTxList"
          border
          @selection-change="handleSelectionChange"
          @sort-change="handleSortChang"
        >
          <!-- <el-table-column type="selection" width="55" align="center" /> -->
          <el-table-column
            type="index"
            header-align="center"
            width="50"
            label="序号"
            fixed="left"
            align="center"
          />
          <el-table-column header-align="center" prop="name" label="用户名称" />
          <el-table-column header-align="center" prop="account" label="用户账号" />
          <el-table-column header-align="center" prop="user_type" label="用户类型" />
          <el-table-column label="账户余额" header-align="center" align="left" prop="account_balance">
            <template slot-scope="scope">
              <span class="text-price">{{ $Prices(scope.row.account_balance) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="提现金额" header-align="center" align="left" prop="tx_amount">
            <template slot-scope="scope">
              <span class="text-price">{{ $Prices(scope.row.tx_amount) }}</span>
            </template>
          </el-table-column>
          <el-table-column header-align="center" prop="province" label="所属大区" />
          <el-table-column label="提现时间" header-align="center" prop="createdAt" width="200">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.tx_time) }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="操作"
            align="center"
            fixed="right"
            width="120"
            class-name="small-padding fixed-width"
          >
            <template slot-scope="scope">
              <router-link :to="{name:'WithdrawalView', params: {id:scope.row.finance_txmx_id}}">
                <el-button size="mini" type="text" icon="el-icon-view">查看</el-button>
              </router-link>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageIndex"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-card>
    </template>
  </BasicLayout>
</template>

<script>
import { txList } from '@/api/admin/sys-finance'
export default {
  name: 'SysWithdrawalManage',
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      visible: false,
      sysTxList: [],
      logisticsList: [],
      // 查询参数
      queryParams: {
        pageIndex: 1,
        pageSize: 10,
        name: undefined,
        account: undefined,
        tx_time: undefined
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询参数列表 */
    getList() {
      this.loading = true
      try {
        txList(this.queryParams)
          .then(response => {
            this.sysTxList = response.data.list
            this.total = response.data.count
          })
          .finally(() => {
            this.loading = false
          })
      } catch (error) {
        console.log(error)
      }
    },
    // 取消按钮
    cancel() {
      this.visible = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {}
      this.resetForm('form')
    },
    parentIdFormat(row) {
      return this.selectItemsLabel(this.parentIdOptions, row.parentId)
    },
    // 文件
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageIndex = 1
      console.log(this.queryParams)
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },

    /** 排序回调函数 */
    handleSortChang(column, prop, order) {
      prop = column.prop
      order = column.order
      if (this.order !== '' && this.order !== prop + 'Order') {
        this.queryParams[this.order] = undefined
      }
      if (order === 'descending') {
        this.queryParams[prop + 'Order'] = 'desc'
        this.order = prop + 'Order'
      } else if (order === 'ascending') {
        this.queryParams[prop + 'Order'] = 'asc'
        this.order = prop + 'Order'
      } else {
        this.queryParams[prop + 'Order'] = undefined
      }
      this.getList()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.consult_wz_id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    }
  }
}
</script>
